﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using eschoolBO;

namespace ESCHOOL
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        admins ad = new admins();
        protected void Page_Load(object sender, EventArgs e)
        {
            Labelerror.Visible = false;
        }

        protected void btnlogin_Click(object sender, EventArgs e)
        {
            DataTable dt = ad.GetRecords(-99, "", tbuname.Text, tbpassword.Text, false, " and ");
            if (dt.Rows.Count > 0)
            {
                Session["userid"] = dt.Rows[0]["userid"].ToString();
                Response.Redirect("~/admin/AdminHome.aspx");
            }
            else
            {
                tbuname.Text = ""; tbpassword.Text = "";
                Labelerror.Visible = true;
                Labelerror.Text = "Login failed,try again!";

                //Response.Redirect("~/AdminLogin.aspx");
            }
        }

        protected void btncancel_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/AdminLogin.aspx");
        }
    }
}
